-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding --json
to lint
#654
Conversation
Thanks a bunch for implementing this! I'd also like to make @alpianon aware of this PR as he asked for the feature IIRC. Then, let me post some remarks and questions:
To reproduce: git clone https://github.com/mxmehl/reuse-example.git test && cd test
git checkout so-many-errors
chmod 000 README.md # also provoke a read error
reuse lint --json The same error also occurs when linting the Linux kernel for example.
Otherwise, it looks good to me so far. It would be interesting to use it against a few concrete test cases. |
This is now fixed by slightly adapting the
This should now be fixed but using a custom JSON serializer.
IMHO, this is probably best treated in a separate PR as it does not only relate to the JSON output of |
Thank you! I can a few first tests and noticed some issues. But first of all, I took the liberty to merge latest master in the branch.
Yes, that makes sense. Now, to the issues I found:
git clone https://github.com/mxmehl/reuse-example.git test && cd test
git checkout json-tests cat.jpgWith my edits, "img/cat.jpg": {
"copyrights": [
{
"value": "SPDX-FileCopyrightText: 2017 Peter Janzen",
"source": "img/cat.jpg.license"
},
{
"value": "Tester Testerson",
"source": "img/cat.jpg.license"
}
],
"licenses": [
{
"value": "CC-BY-4.0",
"source": "img/cat.jpg.license"
},
{
"value": "Apache-2.0",
"source": "img/cat.jpg.license"
}
]
} However, for .gitignoreThat's even more complicated. The file itself contains only copyright info, the ".gitignore": {
"copyrights": [
{
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <[email protected]>",
"source": ".gitignore.license"
}
],
"licenses": [
{
"value": "CC0-1.0",
"source": ".gitignore.license"
}
]
} As you see, the copyright in the file itself is ignored. I think this is intentional as we once decided that such a file can override all contents from the file itself to circumvent false-positive info. We may want to rethink that. However, for some reason, the dep5 info is completely ignored here. I cannot explain why this is different from the |
Thanks for your feedback @mxmehl!
Yes, this was absolutely an issue. The last two commits should have fixed that for JSON and plaintext output respectively.
Yes, I also expect the problem to have deeper roots then this PR. In a sense, we're now exposing REUSE internals (e.g. where a license/copyright information was gathered from) that were not exposed previously. Before JSON output, the tool only really needed to know whether a file had license and copyright information attached to it and whether is info was valid. It didn't really matter where it came from. Now with the much more verbose JSON output we're facing the following issue: It is unclear what to do when license and copyright information is described in two sources, i.e. a .license file and a dep5 file and which one takes precedence. This is related to this docs issue about precedence and also this issue about the undesired merging of copyright information from different sources. My approach to this would be:
IMHO, we would need to include DEP5 here as well as we're not hard deprecating its use.
What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of remarks. I like the bones of this PR. There's just a lot of nitpicking 😅
Adding functions to retrieve and format the data from the `ProjectReport` class.
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Would you please also check if the copyright information is updated in all files you contributed to? It looked to me like some may not have changed, but perhaps those were renamed files.
This commit adds a new enum `SourceType` with three possible values to indicate if the source type is a `.license file`, `file header` or `DEP5 file`. It then updates the usage of `source_type` by replacing the string type with the new `SourceType` enum type. This improves readability and makes the code more maintainable.
Since I worked during my work hours, I'm fine with FSFE holding the copyright. |
This should hopefully close #183.
More tests need to be added and more feedback gathered. This is just a first stab at adding this functionality. Maybe we get it done pre-FOSDEM!
Many thanks!